<template>
    <div class="setting">
        <a-form ref="formRef" auto-label-width :model="form" @submit="handleSubmit">
            <a-form-item label="类型" validate-trigger="input">
                <a-radio-group v-model="form.key" @change="change">
                    <a-radio value="use_provision">使用条款</a-radio>
                    <a-radio value="privacy">隐私协议</a-radio>
                    <a-radio value="common_question">常见问题</a-radio>
                </a-radio-group>
            </a-form-item>
            <a-form-item field="content" hide-label required>
                <ma-editor v-model="form.content" :height="600" />
            </a-form-item>

            <a-form-item hide-label>
                <a-button type="primary" style="margin-right:20px;" html-type="submit">立即提交</a-button>
                <a-button type="outline" @click="$refs.formRef.resetFields()">重置</a-button>
            </a-form-item>
        </a-form>
    </div>
</template>
<script setup>
import request from "@/api/base/setting";
import { Message } from "@arco-design/web-vue";
import { ref } from "vue";
const form = ref({
    key: "use_provision",
    content: ""
});

const get_list = async () => {
    let { data } = await request.get_deta({
        key: form.value.key
    });
    form.value.content = data?.content;
};
get_list();

const change = (e) => get_list();

const handleSubmit = async () => {
    await request.save(form.value);
    Message.success("保存成功");
};
</script>
<style lang="scss" scoped>
.setting {
    padding: 20px;
    box-sizing: border-box;
    background-color: #fff;
}
</style>